<?php

/**
 * @author ZIYAN JUNAIDEEN
 * @copyright 2011
 */

class Database {
    private static $dbo;
    
    private $username   = 'sase_user_db';
    private $password   = 'abc123';
    private $host       = 'localhost'; 
    
    private $connection;
    private $db;
    
    private $mysql_error;
    private $mysql_result;
    
    private function __construct(){
        $this->connection = mysql_connect($this->host, $this->username, $this->password) or 
            die('Error in DB connection ' . PHP_ELO . mysql_error() );
        $this->db = mysql_select_db('sase_db') or die('Error is DB ' . PHP_EOL . mysql_error() );
        //echo 'connected';
    }
    
    public static function getDBOInstance() {
        if (!isset(self::$dbo)) {
            self::$dbo = new Database();
        }
        return self::$dbo;
    }
    
    public function mysql_query($query) {
        //echo '<br>query done  :' . $query . '<br>';
        $result = mysql_query($query) or die (mysql_error());
        
        if ($result) {
            $this->mysql_error = NULL;
            $this->mysql_result = $result;
        }
        else {
            $this->mysql_error = mysql_error($this->connection);
            $this->mysql_result = NULL;
        }
        
        return $result;
    }
    
    public function get_mysql_error() {
        return $this->mysql_error;
    }
    
    public function get_mysql_result() {
        return $this->mysql_result;
    }
}

?>